#!/bin/bash
bit=`getconf LONG_BIT`

if [ $bit != 64 ];then
	echo "抱歉, 不支持32位系统, 请使用64位系统!"
	exit 0
fi

install_docker() {
	if [ `command -v  docker` ];then
		echo "docker 已安装"
	else
		yum install -y yum-utils device-mapper-persistent-data lvm2
		yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
		yum install docker-ce -y
                cp -f daemon.json /etc/docker/
		systemctl enable docker
                systemctl start docker
	fi

	if [ `command -v  docker-compose` ];then
		echo "docker-compose 已安装"
	else
		curl -k -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
		chmod +x /usr/local/bin/docker-compose
	fi
}

install_service() {
	docker-compose up -d
}

install_docker

install_service
